/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.vivo.dealer.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.TreeEntity;

/**
 * 经销商区域Entity
 * @author jyangye
 * @version 2017-11-07
 */
public class VivoArea extends TreeEntity<VivoArea> {
	
	private static final long serialVersionUID = 1L;
	private VivoArea parent;		// 父级编号
	private String parentIds;		// 所有父级编号
	private String name;		// 区域名称
	private Integer sort;		// 排序
	private String code;		// 区域编码
	private String type;		// 区域类型
	private String levelId;		// 区域级别
	private String stateId;		// 区域状态
	
	public VivoArea() {
		super();
	}

	public VivoArea(String id){
		super(id);
	}

	@JsonBackReference
	public VivoArea getParent() {
		return parent;
	}

	public void setParent(VivoArea parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=2000, message="所有父级编号长度必须介于 0 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=1, max=50, message="区域名称长度必须介于 1 和 50 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}
	
	@Length(min=0, max=30, message="区域编码长度必须介于 0 和 30 之间")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	@Length(min=0, max=1, message="区域类型长度必须介于 0 和 1 之间")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Length(min=0, max=32, message="区域级别长度必须介于 0 和 32 之间")
	public String getLevelId() {
		return levelId;
	}

	public void setLevelId(String levelId) {
		this.levelId = levelId;
	}
	
	@Length(min=0, max=32, message="区域状态长度必须介于 0 和 32 之间")
	public String getStateId() {
		return stateId;
	}

	public void setStateId(String stateId) {
		this.stateId = stateId;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}